package com.wunong.smart.address.client.vo;

import lombok.Data;
import org.hibernate.validator.constraints.Length;

import javax.validation.constraints.NotNull;
import java.io.Serializable;

/**
 * 地址值对象
 *
 * @author create by zealot.zt
 */
@Data
public class AddressVO implements Serializable {

    /**
     * 国家编码
     */
    @NotNull(message = "国家编码不能没有")
    protected Integer nationCode;

    /**
     * 省编码
     */
    @NotNull(message = "省编码不能没有")
    protected Long provinceCode;

    /**
     * 城市编码
     */
    @NotNull(message = "城市编码不能没有")
    protected Long cityCode;

    /**
     * 区域编码
     */
    @NotNull(message = "区域编码不能没有")
    protected Long areaCode;

    /**
     * 街道编码
     */
    @Length(max = 32, message = "街道编码长度不能超过32")
    protected String roadCode;

    /**
     * 详细的地址信息，xxx省xxx市xxx区 xxx街道xxx小区xxx栋xxx
     */
    @Length(min = 2, max = 255, message = "详细地址信息字符数不能超过255")
    protected String address;

    public AddressVO() {
    }

    public static AddressVO of(Integer nationCode, Long provinceCode, Long cityCode,
                               Long areaCode, String roadCode, String address) {
        AddressVO vo = new AddressVO();
        vo.setNationCode(nationCode);
        vo.setProvinceCode(provinceCode);
        vo.setCityCode(cityCode);
        vo.setAreaCode(areaCode);
        vo.setRoadCode(roadCode);
        vo.setAddress(address);
        return vo;
    }

}
